package com.buanalintas.sandals.pos.model;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.sandals.pos.entities.PosMasterModel;

public class Model extends Page {
    
    private Field modelId;
    private Field modelName;
    
    public Model() {
        setTheClass(PosMasterModel.class);
        
        modelId = new Field();
        modelId.setName("modelId");
        modelId.setCaption("id");
        modelId.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        modelId.setInputProperties(" size=\"20\"");
        getFields().add(modelId);
        
        modelName = new Field();
        modelName.setName("modelName");
        modelName.setCaption("name");
        modelName.setListProperties(" width=\"95%\" nowrap");
        modelName.setInputProperties(" width=\"30%\" nowrap");
        modelName.setInputCase(Field.CASE_UPPER);
        getFields().add(modelName);
        
        fillFields();
        
        getFieldsUnique().add(new Field[]{modelName});       
        getFieldsAdd().remove(modelId);
        getFieldsEdit().remove(modelId);
        getFieldsList().remove(modelId);

        setExportList(getClass().getResourceAsStream("ModelList.jasper"));
        setExport(getClass().getResourceAsStream("Model.jasper"));       
        getController().setOrder(modelName);
    }

    @Override
    public void beforeView() {
        beforeList();
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "Model"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    } 
}
